package com.ayoka.adapter;

import com.ayoka.R;
import com.ayoka.bean.CourseBean;
import com.ayoka.mvp.CustomerServiceMVP.CustomerServiceModel.MessageOptionBean;
import com.jcp.baselibrary.brvah.BaseQuickAdapter;
import com.jcp.baselibrary.brvah.BaseViewHolder;

import java.util.List;

/**
 * Created by jinchunping on 2018/4/11.
 */

public class CourseDetailMessageOptionAdapter extends BaseQuickAdapter<CourseBean.OptionBean, BaseViewHolder> {

    public CourseDetailMessageOptionAdapter(List<CourseBean.OptionBean> data) {
        super(R.layout.item_course_detail_message_option, data);
    }

    @Override
    protected void convert(final BaseViewHolder holder, CourseBean.OptionBean item) {
        holder.setText(R.id.tv_name, item.Option)
                .setSelected(R.id.tv_name, item.isSelected);
    }

    public void setSingleChoice(int position) {
        for (int i = 0; i < getData().size(); i++) {
            if (getItem(i) == null) continue;
            getItem(i).isSelected = i == position;
        }
        notifyDataSetChanged();
    }
}
